package com.bilibili.xzz.controller;

import com.bilibili.xzz.entity.User;
import com.bilibili.xzz.service.UserService;
import com.bilibili.xzz.utils.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@RestController
@RequestMapping("/api/register")
public class RegisterController {

    @Resource
    UserService userService;

    @PostMapping("/user")
    public Result register(@RequestBody User user){

        int i = userService.setUserByNameAndPwd(user);
        if (i != 0) {
            return Result.ok().data("user","注册成功");
        }
        return Result.error().data("errMsg", "注册失败");
    }
}
